package org.example.com.RabbitMq.Controller;

import org.example.com.RabbitMq.config.FanoutConfig;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class FanoutController {
    @Resource
    private AmqpTemplate amqpTemplate;

    @GetMapping("/fanout/send/fruit")
    public String sendFruit(String msg){
        System.out.println("send fruit order msg:"+msg);
        amqpTemplate.convertAndSend(FanoutConfig.exName,null,msg);
        return "ok";
    }

    //@RabbitListener(queues = FanoutConfig.queueName1)
    public void process1(String msg){
        System.out.println("Receiver fruit msg1:"+ msg);
    }

    //@RabbitListener(queues = FanoutConfig.queueName2)
    public void process2(String msg){
        System.out.println("Receiver other msg2:"+ msg);
    }

    //@RabbitListener(queues = FanoutConfig.queueName3)
    public void process3(String msg){
        System.out.println("Receiver other msg3:"+ msg);
    }

}
